/**
 * @author mili
 */

var map, incidentData, heatmap;
var incidents = [];

function makeIncidents(){
	var obj = parse("incident.json",CONSTANT_INCIDENT);
	var features = obj.features;
	for(var i = 0; i < features.length; i++){
		incidents.push(getLatLng_index(features, i))
	}
}

function initialize(){
	makeIncidents();
	
	var mapOptions = {
          zoom: 12,
          center: new google.maps.LatLng( -33.8674869, 151.2069902),
          mapTypeId: google.maps.MapTypeId.SATELLITE
        };

        map = new google.maps.Map(document.getElementById('map_canvas'),
            mapOptions);

        incidentData = new google.maps.MVCArray(incidents);

        heatmap = new google.maps.visualization.HeatmapLayer({
          data: incidentData
        });

        heatmap.setMap(map);

}

function toogleHeatMap(){
	heatmap.setMap(heatmap.getMap() ? null : map);
}

function changeGradient() {
        var gradient = [
          'rgba(0, 255, 255, 0)',
          'rgba(0, 255, 255, 1)',
          'rgba(0, 191, 255, 1)',
          'rgba(0, 127, 255, 1)',
          'rgba(0, 63, 255, 1)',
          'rgba(0, 0, 255, 1)',
          'rgba(0, 0, 223, 1)',
          'rgba(0, 0, 191, 1)',
          'rgba(0, 0, 159, 1)',
          'rgba(0, 0, 127, 1)',
          'rgba(63, 0, 91, 1)',
          'rgba(127, 0, 63, 1)',
          'rgba(191, 0, 31, 1)',
          'rgba(255, 0, 0, 1)'
        ]
        heatmap.setOptions({
          gradient: heatmap.get('gradient') ? null : gradient
        });
      }

function changeRadius() {
        heatmap.setOptions({radius: heatmap.get('radius') ? null : 20});
      }

function changeOpacity() {
        heatmap.setOptions({opacity: heatmap.get('opacity') ? null : 0.2});
      }



